-
-
Notifications
You must be signed in to change notification settings - Fork 96
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
feat: add url feature #190
Conversation
fake/src/impls/url/mod.rs
Outdated
|
||
impl Dummy<Faker> for Url { | ||
fn dummy_with_rng<R: Rng + ?Sized>(_: &Faker, rng: &mut R) -> Self { | ||
let path: String = Faker.fake_with_rng(rng); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
are arbitrary string can be a valid path?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think it is. If path is [a-zA-Z]
, it must be valid.
However, I think it's better to define paths as const.
FIXED: c736536
fake/src/impls/url/mod.rs
Outdated
impl Dummy<Faker> for Url { | ||
fn dummy_with_rng<R: Rng + ?Sized>(_: &Faker, rng: &mut R) -> Self { | ||
let path: String = Faker.fake_with_rng(rng); | ||
Url::parse(&format!("{FQDN}/{path}")).unwrap() |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
the unwrap may panic due to path is not valid, I think we should make it alway valid path?
#[cfg(test)]
mod test {
use super::*;
#[test]
fn valid_urls_generated() {
for _ in 0..10 {
let url = Faker.fake::<Url>();
println!("{}", url);
}
}
} I tried this test. it worked. |
@cksac |
LGTM. will fix the Clippy warning later |
Thank you @cksac ! |
for issue: #189
I think it's best to use https://example.com/ as a fixed URL.